<template>
  <div>
    <p>{{ count }}秒后自动返回上一页...</p>
  </div>
</template>

<script>
export default {
  props: ["value"],
  data() {
    return {
      count: "",
    };
  },
  mounted() {
    this.$_global.countDownFlag = true;
    this.count = this.value;
    this.countDown();
    //   alert(this.$_global.countDownFlag);
  },
  methods: {
    countDown() {
      let countObj = setInterval(() => {
        if (this.$_global.countDownFlag) {
          this.count--;

          setTimeout(() => {
              this.$router.go(-1);
              this.$_global.countDownFlag = false;
          }, this.count * 1000);
        } else {
          clearInterval(countObj);
        }
      }, 1000);
    },
  },
};
</script>
<style scoped></style>